package org.nepu.scr.domain.datacompleteness.converter;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.domain.datacompleteness.vo.DrillingFluidCertificate;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class DrillingFluidCertificateConverter implements AttributeConverter<DrillingFluidCertificate, String> {
    @Override
    public String convertToDatabaseColumn(DrillingFluidCertificate drillingFluidCertificate) {
        return JSONUtil.toJsonStr(drillingFluidCertificate);
    }

    @Override
    public DrillingFluidCertificate convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, DrillingFluidCertificate.class);
    }
}
